package com.springboot.yuangong.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.springboot.yuangong.entity.Wenjian;
import com.springboot.yuangong.entity.Zhoubao;
import com.springboot.yuangong.entity.vo.WenjianVo;
import com.springboot.yuangong.entity.vo.ZhoubaoVo;
import com.springboot.yuangong.mapper.ZhoubaoMapper;
import com.springboot.yuangong.qpage.QPage;
import com.springboot.yuangong.service.IZhoubaoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.springboot.yuangong.util.Result;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-04-01
 */
@Service
public class ZhoubaoServiceImpl extends ServiceImpl<ZhoubaoMapper, Zhoubao> implements IZhoubaoService {


    /**
     * 分页查询
     * @param qPage
     * @return
     */
    @Override
    public IPage getPageList(QPage qPage, ZhoubaoVo obj) {
        IPage iPage = new Page(qPage.getPage(), qPage.getRows());
        List<ZhoubaoVo> mapList = this.baseMapper.getPageList(iPage,obj);
        return iPage.setRecords(mapList);
    }

    /**
     * 新增
     * @param obj
     * @return
     */
    @Override
    public Result insert(Zhoubao obj) {
        obj.setCtime(new Date());
        this.save(obj);
        return Result.reOk("恭喜，新增成功");
    }

    /**
     * 修改
     * @param obj
     * @return
     */
    @Override
    public Result updates(Zhoubao obj) {
        obj.setUtime(new Date());
        this.updateById(obj);
        return Result.reOk("恭喜，修改成功");
    }


}
